<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>印章管理</title>
</head>
<body class="layui-layout-body">
    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div class="body_right">
            <h4 class="nav_title">设备管理
            </h4>
            <div class="layui-form" >
            		<form action="/devices/list.htm" method="get">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label width60">设备编号</label>
                        <div class="layui-input-inline width150">
                            <input type="text" class="layui-input" name="devicesId" value="${query.devicesId}" placeholder=" 设备编号 ">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label width60">状态</label>
                        <div class="layui-input-block width150">
                            <select name="interest" lay-filter="aihao">
                                <option value="0" selected="">待绑定</option>
                                <option value="1">使用中</option>
                                <option value="2" >已过期</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline width80">
                        <div class="layui-input-inline ">
                            <button class="layui-btn" lay-submit="" lay-filter="demo1" >搜索</button>
                        </div>
                    </div>
                </div>
                </form>
            </div>
            <table class="layui-table  layui-form" mytable" lay-even="" lay-skin="nob">
                <thead>
                <tr>
                    <th>设备编号</th>
                    <th>型号</th>
                     <th>名称</th>
                    <th>开通日期</th>
                    <th>失效日期</th>
                    <th>保管员</th>
                    <th>设备状态</th>
                    <th>启用状态</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                		<#list pm.datas as item>
                    <tr>
                        <td><a href="">${item.devicesCode}</a></td>
                        <td>${item.model}</td>
                        <td>
                        	<#if item.seal??>
                        	${item.seal.sealName}
							</#if>                        
                        </td>
                        <td>
                        		<#if item.installTime??>
                        		${item.installTime?string('yyyy-MM-dd')}
                        		<#else>
                        		未开通
                        		</#if>
                        </td>
                        <td>
                        		<#if item.expireDate??>
                        		${item.expireDate?string('yyyy-MM-dd')}
                        		<#else>
                        			永久
                        		</#if>
                        	</td>
                        	<th>
                        		<#if item.seal??>
                        			${item.seal.custosName}
                        		</#if>
                        	</th>
                        <td>
                        	<#if item.isActivate =='N'>
                        		已禁用
                        	<#else>
                        		<@linkage type="DEVICES_STATUS" key=item.devicesStatus>
                        		<span class="${linkage.style}">${linkage.name}</span>
                        		</@linkage>
                        	</#if>
                        		
                        </td>
                        <td>
                        	<div class="layui-input-inline">
                        		<#if item.seal??>
                    				<input type="checkbox"  name="sealStatus" value="${item.sealId}" <#if item.seal.sealStatus =='ENABLE'>checked=""</#if> lay-skin="switch" lay-filter="sealStatus" lay-text="启用|禁用">
                    			<#else>
                    			 	<input type="checkbox"  name="sealStatus" value=""  lay-skin="switch" lay-filter="runStatus" lay-text="启用|禁用">
                    			</#if>
                    		</div>
                        </td>
                        <td class="allbox_a">
                         <#if item.devicesStatus == 'ACTIVATE'></#if>	
                        	<a href="/devices/setting.htm?devicesId=${item.devicesId}">设置</a> | 
                         
                        	<a href="javascript:openwinx('设备详情','/devices/info.htm?devicesId=${item.devicesId}',800,600);">详情</a>
                        	
                        	<#--
                        	<#if item.devicesStatus =='WAIT_INSTALL'>
                        			<a href="javascript:xconfirm('确认是否完成安装','/devices/install/confirm.htm',{devicesId:'${item.devicesId}'});">确认已安装</a>
                        		</#if>
                        		<#if item.devicesStatus =='WAIT_TEST'>
                        			
                        			<a href="javascript:openwinx('请使用微信扫描二维码安装','/devices/test.htm?devicesId=${item.devicesId}&sealId=${item.sealId}',500,500);">测试</a> | 
                        			
                        		</#if>
                        		
                        		<#if item.devicesStatus =='WAIT_ACTIVATE'>
                        			<a href="javascript:xconfirm('确认是否发布？','/devices/publish.htm',{devicesId:'${item.devicesId}'});">发布</a> 
                        		</#if>
			                     -->   		
                        	
                    	</td>
                    </tr>
                    </#list>
                </tbody>
            </table>
            <@p.page pm=pm></@p.page>

        </div>
     </div>
<script>
layui.use(['form', 'layedit', 'laydate','element'], function(){
  var form = layui.form
  ,layer = layui.layer
  ,element = layui.element
  
  
  //监听指定开关
  form.on('switch(sealStatus)', function(data){
  	
  	var sealId = $(this).val();
  	
  	if(this.checked){
  		ifComfirm('确认是否启用？','/seal/changeStatus.htm',{sealId:sealId});
  	}else{
  		ifComfirm('禁用后设备将无法申请使用，确认禁用？','/seal/changeStatus.htm',{sealId:sealId});
  	}
  });
  
});


function ifComfirm(title,url,parms){
    layer.confirm(title, {icon: 3, title:'提示'}, function(index){
		  if(url){
			  $.ajax({
	      			type:"POST", 
	      			url:url,
	      			data:parms ,
	      			success:function(result) {
			      
			      		if(result.code=='1'){
			      			layer.msg('操作成功');
			      		}else{
			      		 	layer.msg(result.msg);
			      		}
			      
			    	 	} 
			    }); 
		  }
	    layer.close(index);
	});

}

</script>
</body>
</html>